package com.ruoyi.security.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.security.domain.AfRiskIdentification;
import com.ruoyi.security.service.IAfRiskIdentificationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 风险识别Controller
 *
 * @author cjie
 * @date 2021-07-24
 */
@Api(tags = " 风险识别")
@RestController
@RequestMapping("/afRiskIdentification")
public class AfRiskIdentificationController extends BaseController {
    @Autowired
    private IAfRiskIdentificationService afRiskIdentificationService;

    /**
     * 查询风险识别列表
     */
    @ApiOperation(value="查询风险识别列表", notes="查询风险识别列表")
    @PreAuthorize(hasPermi = "security:afRiskIdentification:list")
    @GetMapping("/list")
    public TableDataInfo list(AfRiskIdentification afRiskIdentification) {
        startPage();
        List<AfRiskIdentification> list = afRiskIdentificationService.selectAfRiskIdentificationList(afRiskIdentification);
        return getDataTable(list);
    }

    /**
     * 导出风险识别列表
     */
    @ApiOperation(value="导出风险识别列表", notes="导出风险识别列表")
    @PreAuthorize(hasPermi = "security:afRiskIdentification:export")
    @Log(title = "风险识别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AfRiskIdentification afRiskIdentification) throws IOException {
        List<AfRiskIdentification> list = afRiskIdentificationService.selectAfRiskIdentificationList(afRiskIdentification);
        ExcelUtil<AfRiskIdentification> util = new ExcelUtil<AfRiskIdentification>(AfRiskIdentification.class);
        util.exportExcel(response, list, "风险识别数据");
    }
    /**
     * 获取风险识别详细信息
     */
    @ApiOperation(value="获取风险识别详细信息", notes="获取风险识别详细信息")
    @PreAuthorize(hasPermi = "security:afRiskIdentification:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(afRiskIdentificationService.selectAfRiskIdentificationById(id));
    }

    /**
     * 新增风险识别
     */
    @ApiOperation(value="新增风险识别", notes="新增风险识别")
    @PreAuthorize(hasPermi = "security:afRiskIdentification:add")
    @Log(title = "风险识别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AfRiskIdentification afRiskIdentification) {
        return toAjax(afRiskIdentificationService.insertAfRiskIdentification(afRiskIdentification));
    }

    /**
     * 修改风险识别
     */
    @ApiOperation(value="修改风险识别", notes="修改风险识别")
    @PreAuthorize(hasPermi = "security:afRiskIdentification:edit")
    @Log(title = "风险识别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AfRiskIdentification afRiskIdentification) {
        return toAjax(afRiskIdentificationService.updateAfRiskIdentification(afRiskIdentification));
    }

    /**
     * 删除风险识别
     */
    @ApiOperation(value="删除风险识别", notes="删除风险识别")
    @ApiImplicitParam(name = "ids", value = "风险识别ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "security:afRiskIdentification:remove")
    @Log(title = "风险识别", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(afRiskIdentificationService.deleteAfRiskIdentificationByIds(ids));
    }
}
